<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/20
 * Time: 12:39
 */

namespace App\Http\Controllers\Validator;

use Validator;

class AdminVail
{
    //添加内部账号的验证
    public static function addAdmin($params)
    {
        $validator = Validator::make($params, [
            'a_account'           => 'required',
            'a_user_name'         => 'required',
            'a_sex'               => 'required',
            'a_phone'             => 'required',
            'a_emergency'         => 'required',
            'a_emergency_phone'   => 'required',
            'a_address'           => 'required',
            'a_native_place'      => 'required',
            'a_status'            => 'required'
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }
    //修改内部账号的验证
    public static function editAdmin($params)
    {
        $validator = Validator::make($params, [
            'a_id'                => 'required',
            'a_user_name'         => 'required',
            'a_sex'               => 'required',
            'a_phone'             => 'required',
            'a_emergency'         => 'required',
            'a_emergency_phone'   => 'required',
            'a_address'           => 'required',
            'a_native_place'      => 'required',
            'a_status'            => 'required'
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    //修改密码
    public static function updatePass($params)
    {
        $validator = Validator::make($params, [
            'a_id'          => 'required',
            'oldpass'       => 'required',
            'a_password_again' => 'required',
            'a_password'    => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }
    //登录
    public static function login($params)
    {
        $validator = Validator::make($params, [
            'a_account'          => 'required',
            'a_password'       => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }


    //添加后台管理账号的验证
    public static function add($params)
    {
        $validator = Validator::make($params, [
            'anm_current_grade'     => 'required',
            'anm_current_years'     => 'required',
            'anm_branch_name'       => 'required',
            'anm_area'              => 'required',
            'anm_branch_address'    => 'required',
            'anm_legal'             => 'required',
            'anm_legal_phone'       => 'required',
            'anm_principal'         => 'required',
            'anm_principal_phone'   => 'required',
            'anm_business_license'  => 'required',
            'anm_identity_face'     => 'required',
            'anm_identity_side'     => 'required',
            'anm_app_login'         => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    //修改后台管理账号的验证
    public static function edit($params)
    {
        $validator = Validator::make($params, [
            'anm_id'                      =>  'required',
            'anm_branch_name'             =>   'required',
            'anm_area'                    => 'required',
            'anm_branch_address'          =>   'required',
            'anm_legal'                   =>   'required',
            'anm_legal_phone'             =>   'required',
            'anm_principal'               =>   'required',
            'anm_principal_phone'         =>   'required',
            'anm_business_license'        =>   'required',
            'anm_identity_face'           =>   'required',
            'anm_identity_side'           =>   'required',
            'anm_current_grade'           =>   'required',
            'anm_app_login'               =>   'required',
            'anm_current_years'           =>   'required'
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    //删除图片验证
    public static function delImage($params)
    {
        $validator = Validator::make($params, [
            'anm_id'                      =>  'required',
            'type'                        =>  'required'
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    //单独验证中介公司的ID
    public static function create($params)
    {
        $validator = Validator::make($params, [
            'c_id'             => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    //单独验证中介公司续费的ID
    public static function renew($params)
    {
        $validator = Validator::make($params, [
            'nm_id'             => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }




    //添加后台管理账号的验证
    public static function pay($params)
    {
        $validator = Validator::make($params, [
            'anm_grade'             => 'required',
            'anm_years'             => 'required',
            'anm_id'                => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }

    /**房源客源 获取所有类型下所有种类的验证器
     * @param $params
     * @return bool
     */
    public static function getType($params)
    {
        $validator = Validator::make($params, [
            't_id'          => 'required',
        ]);
        if ($validator->fails()) {
            return  false;
        }
        return true;
    }
}